/*	talmud - The TALMUD roguelike
 * Copyright (C) 2012, talmud contributors
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of Version 2 of the GNU General Public License as published
 *  by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *  FITNESS FOR A PARTICULAR PURPOSE. See Version 2 of the GNU General Public
 *  License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#ifndef item_h
#define item_h

#include <stdint.h>

#define ATKMAX		2

#define I_WEAPON	0
#define I_ARMOR		1
#define I_WAND		2
#define I_POTION	3
#define I_SCROLL	4
#define I_BOOK		5
#define I_TOOL		6
#define I_MISC		7
#define I_CATCOUNT	8

#define S_NONE		0
#define S_BODY		1
#define S_HELM		2
#define S_BOOTS		3
#define S_GLOVES	4
#define S_RING		5
#define S_CLOAK		6
#define S_COUNT		7

#define U_NONE		0
#define U_KEY		1
#define U_BOL		2
#define U_SILVER_PIECE	3

#define ID_NULL			0xFFFF

#define ID_WEAPON_BASE		0
#define ID_DAGGER		0
#define ID_ELVEN_DAGGER		1
#define ID_CURVED_DAGGER	2
#define ID_SILVER_DAGGER	3
#define ID_SHORT_SWORD		4
#define ID_CURVED_SWORD		5
#define ID_NOTCHED_SWORD	6
#define ID_BASTARD_SWORD	7
#define ID_LONG_SWORD		8
#define ID_CLAYMORE		9
#define ID_MACE			10
#define ID_CLUB			11
#define ID_WOODEN_STAKE		12
#define ID_SICLE		13
#define ID_WEAPON_COUNT		14

#define ID_ARMOR_BASE		14
#define ID_LEATHER_ARMOR	14
#define ID_BUCKLED_LEATHER_SUIT	15
#define ID_ELVEN_LEATHER_ARMOR	16
#define ID_RING_MAIL		17
#define ID_CHAIN_MAIL		18
#define ID_ARMOR_COUNT		5

#define W_NONE		0
#define W_FIRE		1
#define W_COLD		2
#define W_LIGHTNING	3
#define W_FORCE		4
#define W_TELEPORTATION	5
#define W_INVISIBILITY	6
#define W_MARKING	7
#define W_SLEEP		8
#define W_CHARMING	9
#define W_COUNT		10

#define ID_WAND_BASE		19
#define ID_WAND_OF_FIRE		19
#define ID_WAND_OF_COLD		20
#define ID_WAND_OF_LIGHTNING	21
#define ID_WAND_OF_FORCE	22
#define ID_WAND_OF_TELE		23
#define ID_WAND_OF_INVIS	24
#define ID_WAND_OF_MARKING	25
#define ID_WAND_OF_SLEEP	26
#define ID_WAND_OF_CHARMING	27
#define ID_WAND_COUNT		9

#define P_WATER		0
#define P_HEALING	1
#define P_FULLHEALING	2
#define P_INVISIBILITY	3
#define P_PARALYSIS	4
#define P_SLEEPING	5
#define P_CONFUSION	6
#define P_POISON	7
#define P_INFRAVISION	8
#define P_GAIN_LEVEL	9
#define P_COUNT		10

#define ID_POTION_BASE		28
#define ID_POT_OF_WATER		28
#define ID_UNID_POT_BASE	29
#define ID_POT_OF_HEALING	29
#define ID_POT_OF_FULL_HEALING	30
#define ID_POT_OF_INVISIBILITY	31
#define ID_POT_OF_PARALYSIS	32
#define ID_POT_OF_SLEEPING	33
#define ID_POT_OF_CONFUSION	34
#define ID_POT_OF_POISON	35
#define ID_POT_OF_INFRAVISION	36
#define ID_POT_OF_GAIN_LEVEL	37
#define ID_POTION_COUNT		10

#define ID_SCROLL_BASE		0
#define ID_SCROLL_COUNT		0

#define ID_BOOK_BASE		38
#define ID_BOOK_OF_LIFE		38
#define ID_BOOK_COUNT		1

#define ID_TOOL_BASE		39
#define ID_KEY			39
#define ID_TOOL_COUNT		1

#define ID_MISC_BASE		40
#define ID_SILVER_PIECE		40
#define ID_MISC_COUNT		1

#define ID_COUNT		41

#define B_NONE		0
#define B_CURSED	1
#define B_UNHOLY	2
#define B_HOLY		3
#define B_UNKNOWN	0xFF

#define UNID_NONE	0
#define UNID_WAND	1
#define UNID_POT	2

typedef struct itemdef_s
{
	const char *name;
	uint8_t type;
	uint8_t unidslot;
	uint8_t slot;
	uint8_t baseac;
	uint8_t weight;
	uint16_t intrins;
	int8_t tohit;
	uint8_t atkcount;
	uint8_t hdcount[ATKMAX];
	uint8_t hd[ATKMAX];
	uint8_t utility;
	uint16_t maxstack;
	uint8_t freq;
	uint8_t maxgenstack;
	uint8_t attr;
} itemdef_t;

typedef struct item_s
{
	uint8_t type;
	int8_t enchant;
	uint16_t count;
	uint8_t holiness;
	uint8_t knownholy;
	uint8_t ided;
	uint8_t x;
	uint8_t y;
	uint8_t dlvl;
	uint8_t branch;
} item_t;

extern const char * const SLOTNAMES[];
extern const itemdef_t ITEMDEFS[ID_COUNT];
extern const char * const ITEMTYPESTRS[];

item_t BuildItem(uint8_t type, int8_t enchant, uint8_t holiness);
const char *ItemDesc(const item_t *item, uint8_t invidx);

#endif
